package com.offcn.sessiondemo.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import javax.websocket.Session;

@RestController
public class MyController {
    @RequestMapping("/set")
    public String setSession(HttpSession session){
        session.setAttribute("username","lucy");
        System.out.println("设置session");
        return "success";
    }
    @RequestMapping("get")
    public String getSession(HttpSession session){
        session.getAttribute("username");
        System.out.println("获得session");
        return "lucy";
    }
}